package io.jee.runshan.domain;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "runshan_order_presale")
public class PreSaleOrder {
	private Integer id;
	private String wxOpenid;
	private String orderCode;// 订单号
	private String QRCode; // 订单二维码
	private BigDecimal fullAmount; // 全款金额
	private BigDecimal preAmount; // 预付款
	private Integer status = 99; // 状态：0-已下单，待支付预付款；1-已支付预付款；3-已完成；97-自动取消；98-客户退订申请中；99-客户退订；100-退款成功；
	private String alipayAccount; // 支付宝账号
	private VIP vip;
	private OrderContact contact; // 联系人
	private Date orderTime; // 下单时间
	private Date cancelTimer; // 订单自动取消时间
	private Date payTime; // 预付款付款时间
	private Boolean showed = true;
	private Set<PreSaleOrderProduct> orderProducts; // 商品
	private String alipaySerial; // 支付宝流水号
	private String documentSerial; // 单据号

	public void addProduct(PreSaleOrderProduct product) {
		if (orderProducts == null) {
			orderProducts = new HashSet<PreSaleOrderProduct>();
		}
		orderProducts.add(product);
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getWxOpenid() {
		return wxOpenid;
	}

	public void setWxOpenid(String wxOpenid) {
		this.wxOpenid = wxOpenid;
	}

	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	public String getQRCode() {
		return QRCode;
	}

	public void setQRCode(String qRCode) {
		QRCode = qRCode;
	}

	public BigDecimal getFullAmount() {
		return fullAmount;
	}

	public void setFullAmount(BigDecimal fullAmount) {
		this.fullAmount = fullAmount;
	}

	public BigDecimal getPreAmount() {
		return preAmount;
	}

	public void setPreAmount(BigDecimal preAmount) {
		this.preAmount = preAmount;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getAlipayAccount() {
		return alipayAccount;
	}

	public void setAlipayAccount(String alipayAccount) {
		this.alipayAccount = alipayAccount;
	}

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
	public Set<PreSaleOrderProduct> getOrderProducts() {
		return orderProducts;
	}

	public void setOrderProducts(Set<PreSaleOrderProduct> orderProducts) {
		this.orderProducts = orderProducts;
	}

	@ManyToOne
	public OrderContact getContact() {
		return contact;
	}

	public void setContact(OrderContact contact) {
		this.contact = contact;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public Date getPayTime() {
		return payTime;
	}

	public void setPayTime(Date payTime) {
		this.payTime = payTime;
	}

	@ManyToOne
	public VIP getVip() {
		return vip;
	}

	public void setVip(VIP vip) {
		this.vip = vip;
	}

	public Date getCancelTimer() {
		return cancelTimer;
	}

	public void setCancelTimer(Date cancelTimer) {
		this.cancelTimer = cancelTimer;
	}

	public Boolean getShowed() {
		return showed;
	}

	public void setShowed(Boolean showed) {
		this.showed = showed;
	}

	public String getAlipaySerial() {
		return alipaySerial;
	}

	public void setAlipaySerial(String alipaySerial) {
		this.alipaySerial = alipaySerial;
	}

	public String getDocumentSerial() {
		return documentSerial;
	}

	public void setDocumentSerial(String documentSerial) {
		this.documentSerial = documentSerial;
	}

}
